home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
util
/
time
/
backclock.lha
/
BackClock
/
sources
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-02-08
|
3KB
|
98 lines
/*****************************************************************************
*
* Nom : main.c
*
* version : $VER: main.c 1.1 (06.02.98)
*
* History
* V1.0: initial version
* V1.1: can be started from WB with Tooltypes
* added notifyintuition routines to close the window automatically
* v1.2: window can initialy sized thanks to tooltypes
* window goes to back every seconds
* first public release
*****************************************************************************
*/
#include <intuition/intuition.h>
#include <dos/dos.h>
#include <exec/ports.h>
#include <exec/libraries.h>
#include <exec/memory.h>
#include <workbench/startup.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include "utils.h"
/* bump revision
*/
char * nosense = "\0$VER: " TITLE " (06.02.98)" ;
struct Library * IconBase ;
void main() {
/* lance du CLI
*/
idWin * myprj ;
if (exists() == FALSE) {
if ((myprj = init(NULL)) != NULL) {
//writeDate(myprj) ;
processwin(myprj) ;
}
close(myprj) ;
}
}
void wbmain(struct WBStartup * wbmess) {
/* lance du WB
*/
idWin * myprj ;
if (exists() == FALSE ) {
if ((IconBase = OpenLibrary("icon.library", 37)) != NULL) {
if ((myprj = init(wbmess->sm_ArgList)) != NULL) {
processwin(myprj) ;
}
close(myprj) ;
CloseLibrary(IconBase) ;
}
}
}
int exists() {
int ret = FALSE ;
struct EasyStruct EZ ;
struct MsgPort * oldPort ;
struct MsgPort * replyPort ;
struct backMsg * msg ;
Forbid() ;
oldPort = FindPort("backclock") ;
Permit() ;
if (oldPort) {
/* le programme est deja lance
*/
EZ.es_StructSize = sizeof(struct EasyStruct) ;
EZ.es_Flags = NULL ;
EZ.es_Title = TITLE ;
EZ.es_TextFormat = "You are about to quit BackClock\nAre you sure ?" ;
EZ.es_GadgetFormat = "Quit|Cancel" ;
if (EasyRequestArgs(NULL, &EZ, NULL, NULL) == 1) {
/* utilisateur choisit quit
*/
if ((replyPort = CreateMsgPort()) != NULL) {
if ((msg = AllocVec(sizeof(struct backMsg), MEMF_PUBLIC)) != NULL) {
msg->execmsg.mn_Node.ln_Type = NT_MESSAGE ;
msg->execmsg.mn_Length = sizeof(struct backMsg) ;
msg->execmsg.mn_ReplyPort = replyPort ;
PutMsg(oldPort, (struct Message*)msg) ;
WaitPort(replyPort) ;
DeleteMsgPort(replyPort) ;
FreeVec(msg) ;
ret=OK ;
}else {
ret=ERRORNOMEM ;
DeleteMsgPort(replyPort) ;
}
}else ret=ERRORNOMEM ;
}else ret = OK ;
}
return(ret) ;
}